package array.simple;

/**
 * 移动零
 * 输入: [0,1,0,3,12]
 * 输出: [1,3,12,0,0]
 *
 * 链接：https://leetcode-cn.com/problems/move-zeroes
 */
public class MoveZeroes_283 {

    public void moveZeroes(int[] nums) {
        int i = 0, j = 0;
        while(i < nums.length) {
            if (nums[i] != 0)
                nums[j++] = nums[i];
            i++;
        }
        while(j < nums.length)
            nums[j++] = 0;
    }

    public static void main(String[] args) {
        MoveZeroes_283 mz = new MoveZeroes_283();
        mz.moveZeroes(new int[]{0, 0, 1,2,0,0,0,5,0,7});
    }


}
